# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>

pkgname=python-josepy
_pkgname=josepy
pkgver=1.13.0
pkgrel=3
pkgdesc="JOSE protocol implementation in Python"
url="https://github.com/certbot/josepy"
license=('PerlArtistic')
arch=('any')
depends=(
  'python-cryptography'
  'python-pyopenssl'
)
makedepends=('python-setuptools')
checkdepends=('python-pytest')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz"{,.asc})
sha512sums=('fb91946ac4bbb2a81195d200e4fdf06d40865b345005ab4ee328fd72545da2345b44c5b9ffb3115b16ffed65ab3a0c01d5b20d0d2ff3c2c2af30537a6a4721df'
            'SKIP')
b2sums=('e4f3caed3be0775a49d6a9c38bf6e2b61ecc50b4e3804afa9e597b741821ab63a27fe95d1592531fee7152e2076760d838f4efa50ab8b3e2f1e129c9d7457f8c'
        'SKIP')
validpgpkeys=('20F201346BF8F3F455A73F9A780CC99432A28621')

prepare() {
  cd "$_pkgname-$pkgver"

  # thou shalt not enforce coverage in distro packaging
  # https://github.com/certbot/josepy/issues/34
  rm pytest.ini

  # nuke setuptools from orbit ^W install_requires
  sed \
    -e '/setuptools>=/d' \
    -i setup.py
}

build() {
  cd "$_pkgname-$pkgver"

  python setup.py build
}

check() {
  cd "$_pkgname-$pkgver"

  PYTHONPATH="$PWD/build/lib" pytest
}

package() {
  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --optimize=1
}
